import db from '../../xp/db';
import * as util from '../../../util';

export function fetch(query, op, pageOpt) {
    return db.get('xp_activitytype').query(qb => {
        if (query) {
            util.andWhere(query, op, qb);
        }
    }).fetchPage({
        pageSize: pageOpt.pageSize,
        page: pageOpt.page
    });
}
export function find(query, op) {
    return db.get('xp_activitytype').query(qb => {
        if (query) {
            util.andWhere(query, op, qb);
        }
        qb.orderBy('displayOrder');
    }).list();
}
export function add(data) {
    return db.get('xp_activitytype').forge().save(data, {method: 'insert'});
}
export function edit(data) {
    return db.get('xp_activitytype').forge().save(data, {method: 'update', require: false});
}
export function del(id) {
    return db.get('xp_activitytype').forge({id}).drop();
}
